<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>4.寻找两个正序数组的中位数</title>
</head>

<body>

</body>

<script>
    /**
    * @param {number[]} nums1
    * @param {number[]} nums2
    * @return {number}
    */
    var findMedianSortedArrays = function (nums1, nums2) {
        let arr = nums1.concat(nums2).sort((a, b) => a - b);
        if (arr.length % 2 == 0) {
            return (arr[arr.length / 2] + arr[arr.length / 2 - 1]) / 2;
        } else {
            return arr[Math.floor(arr.length / 2)];
        }
    };
    console.log(findMedianSortedArrays([1, 2], [3, 4]));
</script>

</html>